﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:params="http://schemas.codeplex.com/elysium/params">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Elysium;component/Themes/Generic.xaml"/>
        <ResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/FocusVisualStyle.xaml"/>
        <ResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Geometry.xaml"/>
        <ResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Validation.xaml"/>
        <ResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/Watermark.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}"/>
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}"/>
        <Setter Property="CaretBrush" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}"/>
        <Setter Property="FontStretch" Value="Medium"/>
        <Setter Property="FontStyle" Value="Normal"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
        <Setter Property="SelectionBrush" Value="{StaticResource MiddleLightBrush}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefaultWatermarkTemplate}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:ButtonTextBox}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <ScrollViewer x:Name="PART_ContentHost"
                                          Background="{x:Null}"
                                          Foreground="{TemplateBinding Foreground}"
                                          FontSize="{TemplateBinding FontSize}"
                                          FontStretch="{TemplateBinding FontStretch}"
                                          FontStyle="{TemplateBinding FontStyle}"
                                          FontWeight="{TemplateBinding FontWeight}"
                                          TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                                          TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                                          RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                                          Margin="{TemplateBinding Padding}"/>
                            <ContentPresenter x:Name="PART_Watermark"
                                              Content="{TemplateBinding Watermark}"
                                              ContentTemplate="{TemplateBinding WatermarkTemplate}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              IsHitTestVisible="False"
                                              Margin="{TemplateBinding Padding}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              Visibility="Collapsed"/>
                            <Button x:Name="PART_Button" 
                                    Grid.Column="1"
                                    Command="{TemplateBinding Command}"
                                    CommandParameter="{TemplateBinding CommandParameter}"
                                    Content="{TemplateBinding Content}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                    MinWidth="20"
                                    Padding="6, 0, 6, 0"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsFocused" Value="False"/>
                                <Condition Property="Text" Value=""/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter Property="Visibility" TargetName="PART_Watermark" Value="Visible"/>
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsKeyboardFocusWithin" Value="True"/>
                    <Condition Property="IsReadOnly" Value="False"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal"/>
            </DataTrigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource DisabledBrush}"/>
            </Trigger>
            <Trigger Property="Validation.HasError" Value="True">
                <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorControlTemplate}"/>
                <Setter Property="Background" Value="{StaticResource ValidationErrorBrush}"/>
                <Setter Property="CaretBrush" Value="{StaticResource ForegroundBrush}"/>
                <Setter Property="ToolTip" Value="{StaticResource ValidationErrorToolTip}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="ButtonTextBoxBaseStyle" BasedOn="{StaticResource {x:Type controls:ButtonTextBox}}" TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Path Data="{Binding}" 
                          Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, Path=Foreground, Mode=OneWay}" 
                          Height="16"
                          Stretch="Uniform" 
                          Width="16"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="SearchButtonTextBoxStyle" BasedOn="{StaticResource ButtonTextBoxBaseStyle}" TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="Content" Value="{StaticResource SearchGeometry}"/>
        <Setter Property="Watermark" Value="Search"/>
    </Style>
    <Style x:Key="LargeSearchButtonTextBoxStyle" BasedOn="{StaticResource SearchButtonTextBoxStyle}" TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Path Data="{Binding}" 
                          Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, Path=Foreground, Mode=OneWay}" 
                          Height="24"
                          Stretch="Uniform" 
                          Width="24"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.HeaderFontSize)}"/>
    </Style>
    <Style x:Key="FolderButtonTextBoxStyle" BasedOn="{StaticResource ButtonTextBoxBaseStyle}" TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="Content" Value="{StaticResource FolderGeometry}"/>
    </Style>
    <Style x:Key="RefreshButtonTextBoxStyle" BasedOn="{StaticResource ButtonTextBoxBaseStyle}" TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="Content" Value="{StaticResource Refresh1Geometry}"/>
    </Style>
    <Style x:Key="ClearButtonTextBoxStyle" BasedOn="{StaticResource ButtonTextBoxBaseStyle}" TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="Content" Value="{StaticResource ClearGeometry}"/>
    </Style>
    <Style x:Key="LargeClearButtonTextBoxStyle" BasedOn="{StaticResource ClearButtonTextBoxStyle}" TargetType="{x:Type controls:ButtonTextBox}">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Path Data="{Binding}" 
                          Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, Path=Foreground, Mode=OneWay}" 
                          Height="24"
                          Stretch="Uniform" 
                          Width="24"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.HeaderFontSize)}"/>
    </Style>

</ResourceDictionary>